// 变量定义
@card-border: rgba(64, 169, 255, 0.3);
@text-color: #fff;
@accent-color: #40a9ff;
@header-height: 24px;
@card-padding: 0px;
@list-item-height: 40px;

.current-warning-card {
  width: 320px;
  height: 320px;
  top: 120px;
  right: 16px;
  position: fixed;
  // 使用border-image实现9切片缩放效果
  border-style: solid;
  border-width: 12px; // 设置足够的边框宽度用于切片
  border-image: url("@/assets/images/png/bg-panel-alert.png") 20 fill stretch;
  // 确保border-image在折叠状态下也正常显示
  &.collapsed {
    border-image: url("@/assets/images/png/bg-panel-alert.png") 20 fill stretch;
  }

  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  z-index: 10;
  // 禁止文字选中
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;

  // 折叠状态
  &.collapsed {
    height: 50px;
    // 折叠时只显示标题栏
    .card-content {
      display: none;
    }
  }

  .card-header {
    // 标题栏高度固定
    height: @header-height;
    display: flex;
    align-items: center;
    padding: 0 @card-padding;
    margin-bottom: 8px;

    .panel-icon {
      width: 14px;
      height: 14px;
      object-fit: contain;
      background: url("@/assets/images/png/panel-icon.png") no-repeat;
      background-size: 100% 100%;
      flex-shrink: 0; // 防止被压缩
      margin-right: 8px;
    }

    .header-content {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;

      .card-title {
        font-size: 14px;
        font-weight: bold;
        color: @text-color;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    .collapse-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 24px;
      color: @accent-color;
      cursor: pointer;
      border-radius: 2px;
      transition: all 0.3s ease;
      margin-left: 8px;

      .collapse-icon {
        width: 14px;
        height: 14px;
        background: url("@/assets/images/png/arrow-up.png") no-repeat;
        background-size: 100% 100%;
        transition: transform 0.3s ease;
      }

      &.collapsed .collapse-icon {
        transform: rotate(180deg);
      }
    }
  }

  .card-content {
    display: flex;
    flex-direction: column;
    color: @text-color;
    font-size: 12px;
    padding: 0;
    height: calc(100% - @header-height - 8px); // 固定内容区域高度，减去标题栏高度和间距
    overflow: hidden; // 禁用外部滚动
    overflow: hidden;
  }

  // 告警列表样式
  .list-body {
    height: 100%; // 完全填充父容器高度
    overflow-y: auto; // 垂直方向可滚动

    // 滚动条样式
    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background-color: rgba(255, 255, 255, 0.3);
      border-radius: 3px;
    }

    &::-webkit-scrollbar-thumb:hover {
      background-color: rgba(255, 255, 255, 0.5);
    }

    .list-item {
      display: flex;
      // 移除固定高度限制，让高度自适应内容
      min-height: @list-item-height;
      padding: 4px 0; // 添加上下内边距
      align-items: center; // 改为垂直居中
      transition: background-color 0.2s ease;

      // 奇数行背景色
      &:nth-child(odd) {
        background-color: rgba(6, 47, 93, 1);
      }

      // 偶数行背景色
      &:nth-child(even) {
        background-color: rgba(30, 82, 132, 1);
      }

      &:hover {
        .list-col {
          color: rgb(255, 255, 255);
        }
      }

      &:last-child {
        border-bottom: none;
      }
    }

    .list-col {
      padding: 0 4px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: normal; // 允许换行
      color: rgba(255, 255, 255, 1);
      font-size: 12px; // 设置字体大小为12px
      text-align: center; // 水平方向居中对齐

      &.serial-col {
        width: 100px;
        text-align: right;
      }

      &.category-col {
        width: 200px;
      }

      &.address-col {
        flex: 1;
        min-width: 120px;
      }

      &.time-col {
        width: 280px;
      }
    }
  }
  .list-footer {
    display: flex;
    justify-content: center;
    .ant-pagination {
      font-size: 11px;
      color: white;
    }
  }
  .ant-pagination .ant-pagination-prev button {
    color: white;
  }
  .ant-pagination .ant-pagination-next button {
    color: white;
  }
  .loading-container {
    position: absolute;
    width: 100%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.2);
    &.hidden {
      display: none;
    }
    .loading-icon {
      font-size: 32px;
      color: rgb(65, 132, 248);
    }
  }
}
